home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / More Source / C⁄C++ / Xconq 7.0d37 / source / mac / mactextldef.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-07-23  |  1.9 KB  |  61 lines  |  [TEXT/KAHL]

  1. /* Minimal text LDEF, no fancy features, stripped down from a version by Adam Winer (?).
  2.    Copyright (C) 1993, 1994 Stanley T. Shebs.
  3.  
  4. Xconq is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2, or (at your option)
  7. any later version.  See the file COPYING.  */
  8.  
  9. /* Spacing parameters. */
  10.  
  11. #define kLeftOffset    2
  12. #define kTopOffset    0
  13.  
  14. pascal void
  15. main(short listmsg, Boolean selected, Rect *listrectptr, Cell listcell,
  16.      short listdataoffset, short listdatalength, ListHandle listhandle)
  17. {
  18.     FontInfo fontInfo;
  19.     ListPtr listptr;
  20.     SignedByte hStateList, hStateCells;
  21.     Ptr celldata;
  22.     short leftdraw, topdraw, wayleft;
  23.     
  24.     /* Lock and dereference the list and cell data handles. */    
  25.     hStateList = HGetState((Handle) listhandle);
  26.     HLock((Handle) listhandle);
  27.     listptr = *listhandle;
  28.     hStateCells = HGetState(listptr->cells);
  29.     HLock(listptr->cells);
  30.     celldata = *(listptr->cells);
  31.     /* Decipher the desired action on the list. */
  32.     switch (listmsg) {
  33.       case lInitMsg:
  34.           /* We don't need any initialization. */
  35.           break;
  36.       case lDrawMsg:
  37.         EraseRect(listrectptr);
  38.           if (listdatalength > 0) {
  39.               /* Determine starting point for drawing. */
  40.               wayleft = listcell.h * listptr->cellSize.h + listptr->rView.left;
  41.               leftdraw = wayleft + listptr->indent.h + kLeftOffset;
  42.               topdraw = listrectptr->top + listptr->indent.v + kTopOffset;
  43.             GetFontInfo(&fontInfo);
  44.             MoveTo(leftdraw, topdraw + fontInfo.ascent);
  45.             TextFace(0);
  46.             DrawText(celldata, listdataoffset, listdatalength);
  47.           }
  48.         if (!selected) break;
  49.         /* Fall through to draw selected cell in hilite color. */
  50.       case lHiliteMsg:
  51.           /* Do hilite color. */
  52.           BitClr(&HiliteMode, pHiliteBit);
  53.           InvertRect(listrectptr);
  54.           break;
  55.       case lCloseMsg:
  56.           break;
  57.     }
  58.     HSetState(listptr->cells, hStateCells);
  59.     HSetState((Handle) listhandle, hStateList);
  60. }
  61.